#include "../include/stu.h"

void insert_c(){
    system("clear");
    printf("输入课程信息：\n");
    printf("退出：-1\n");
    printf("课程号\t课程名\t课程性质\t学时\t学分\t已选人数\t可选人数\n");
    struct course *p1,*p2,*p3;
    p2 = (struct course *)malloc(sizeof(struct course));
    scanf("%d",&p2->id);
    if(p2->id == -1)
        return ;
    scanf("%s %s %d %d %d %d",p2->name,p2->type,&p2->time,&p2->credit,&p2->selectde,&p2->limit);
    
    if(head2 == NULL){
        head2 = p2;
        printf("success1\n");
    }else{
        p1 = head2;
        p3 = p1;
        while(p1 != NULL){
            if(p1->id == p2->id){
                printf("该课程号存在，重新输入\n");
                return ;
            }
            p3 = p1;
            p1 = p1->next;
        }
        p3->next = p2;
        p2->next = NULL;
        printf("success2\n");
    }
}
